package georah.map.graphics
{

	import flash.display.Sprite;

	/**
	 *
	 * @author yuanm
	 */
	public final class SimpleMarker extends MapGraphic
	{
		public static const OVAL:String="OVAL";

		public static const RECT:String="RECT";

		public var backgroundAlpha:Number=1;

		public var backgroundColor:int=0x000000;

		public var shapeType:String=SimpleMarker.OVAL;

		override public function clone():MapGraphic
		{
			var m:SimpleMarker=new SimpleMarker();
			m.width=width;
			m.height=height;
			m.backgroundAlpha=backgroundAlpha;
			m.backgroundColor=backgroundColor;
			m.shapeType=shapeType;
			return m;
		}

		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
		{
			super.updateDisplayList(unscaledWidth, unscaledHeight);

			container.x=-0.5 * unscaledWidth;
			container.y=-0.5 * unscaledHeight;

			container.graphics.beginFill(backgroundColor, backgroundAlpha);
			switch (shapeType)
			{
				case SimpleMarker.OVAL:
					container.graphics.drawCircle(0.5 * unscaledWidth, 0.5 * unscaledHeight, 0.5 * (Math.min(unscaledWidth, unscaledHeight)));
					break;
				case SimpleMarker.RECT:
					container.graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
					break;
			}
			container.graphics.endFill();
		}

	}
}
